package com.sui.bigdata.flink.sql.function.scalar;


import com.sui.bigdata.flink.sql.function.util.SimpleAES;

import org.apache.flink.table.functions.ScalarFunction;

public class AESDecrypt extends ScalarFunction {
    private static String passwd = "&*($HJDGH4867%&T345386754OHYOH*^(ughiuR5fu&f&$KHAOS$&^%t";

    public String eval(String value) {
        if (value == null) {
            return null;
        }
        try {
            return SimpleAES.decrypt(value.toString(), AESDecrypt.passwd).replaceAll("[\\t\\n\\r]", "");
        } catch (Exception e) {
        }
        return value;
    }

    public static void main(String[] args) {
        AESDecrypt aesDecrypt = new AESDecrypt();
        System.out.println(aesDecrypt.eval("3156392dff45157c5de953cade5a1590"));
    }
}
